<!DOCTYPE html>
<html lang="zh-cn">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <link rel="stylesheet" href="css/Global2.css" />
    <link rel="stylesheet" href="css/style2.css" />
    <title>天津二手房评估</title>
    <style>
      body {
        -webkit-user-select: none;
        -moz-user-select: none;
        -ms-user-select: none;
        user-select: none;
        cursor: default;
      }
      .schoolInfo {
        display: none;
      }
      .submit-btn {
        width: 200px;
      }
      .mb20{margin-bottom: 1rem;border-bottom: 1px solid #eee;}
    </style>
  </head>

  <body>
    <div class="bg-white" style="padding:1rem 2rem;">
      <div class="tc">
        <h2 class="f40 fw8 text-red h-70">房屋估价</h2>
        <p class="mb-10 f14">
          如您输入的信息准确无误，48小时后请您到本网站查询结果。此价格仅供参考，谢谢您的使用，如您在本公司申请业务，将以实地验房后的估价结果为准。请确保您的联系方式准确无误！我们将会和您联系。
        </p>
      </div>
    </div>
    <div class="bg-grey">
      <div class="">
        <form action="" class="form form1" id="myform">
          <div class="bold mb20">联系方式</div>
          <div class="item">
            <label>客户姓名</label>
            <input
              class="w500"
              type="text"
              placeholder="请输入"
              name="customerName"
              id="customerName"
            />
          </div>
          <div class="item">
            <label>联系电话</label>
            <input
              class="w500"
              type="text"
              placeholder="请输入"
              name="phoneNumber"
              id="phoneNumber"
            />
          </div>
          <div class="item">
            <label>详细地址</label>
            <input
              class="w500"
              type="text"
              placeholder="建议您按照房本信息填写"
              name="address"
              id="address"
            />
          </div>
          <div class="bold mb20">房屋详细</div>
          <div class="item">
            <label>区域</label>
            <div class="input ovh">
              <select
                class="input g9"
                name="district"
                id="district"
              ></select>
            </div>
          </div>
          <!-- district=='和平' -->
          <div class="item schoolInfo">
            <label>学区</label>
            <div class="input ovh">
              <select
                class="input g9"
                name="schoolInfo"
                id="schoolInfo"
              ></select>
            </div>
          </div>
          <!-- district=='和平' -->
          <div class="item">
            <label>房型</label>
            <div class="input ovh">
              <select
                class="input g9"
                name="houseType"
                id="houseType"
              ></select>
            </div>
          </div>
          <div class="item">
            <label>产别</label>
            <div class="input ovh">
              <select
                class="input g9"
                name="ownerShip"
                id="ownerShip"
              ></select>
            </div>
          </div>
          <div class="item">
            <label>朝向</label>
            <div class="input ovh">
              <select
                class="input g9"
                name="orientation"
                id="orientation"
              ></select>
            </div>
          </div>
          <div class="item">
            <label>结构</label>
            <div class="input ovh">
              <select
                class="input g9"
                name="structure"
                id="structure"
              ></select>
            </div>
          </div>
          <div class="item">
            <label>物业</label>
            <div class="input ovh">
              <select
                class="input g9"
                name="property"
                id="property"
              ></select>
            </div>
          </div>
          <div class="item">
            <label>装修</label>
            <div class="input ovh">
              <select
                class="input g9"
                name="renovation"
                id="renovation"
              ></select>
            </div>
          </div>
          <div class="item">
            <label>楼层</label>
            <input
              class="w500"
              type="text"
              placeholder="当前层/共几层，如3/10"
              name="floor"
              id="floor"
            />
          </div>
          <div class="item">
            <label>面积</label>
            <input
              class="w500"
              type="text"
              placeholder="请输入建筑面积"
              name="area"
              id="area"
            />
          </div>
            <div class="f14 text-orange mb-10">提示：如为伙用请用该公式计算面积:独用+伙用/伙用户数</div>
          <div class="item">
            <label>房本编号</label>
            <input
              class="w500"
              type="text"
              placeholder="请输入"
              name="houseId"
              id="houseId"
            />
          </div>
          <p class="m-auto submit-btn">
            <!-- <input type="button" value="提交信息" class="submit-btn"> -->
            提交信息
          </p>
        </form>
      </div>
    </div>
    <script src="js/jquery-3.5.1.js"></script>
    <script src="js/request.js"></script>
    <script src="js/all.js"></script>
    <script>
      // var commomUrl = "https://rht-test.jfzh.com.cn/",
      var commomUrl = "https://rht.jfzh.com.cn/",
        info = JSON.parse(localStorage.getItem("userInfo")), //判断是否登录
        address = null,
        area = null,
        schoolInfo = null,
        customerName = null,
        decorationType = null,
        district = null,
        floor = null,
        houseType = null,
        houseId = null,
        houseOrientation = null,
        ownerShip = null,
        phoneNumber = null,
        propertyManagementCompanyType = null,
        structure = null,
        SchoolInfoList = [
          {
            id: "1",
            name: "2015年至今无入学记录",
          },
          {
            id: "2",
            name: "2016年有入学记录",
          },
          {
            id: "3",
            name: "2017年有入学记录",
          },
          {
            id: "4",
            name: "2018年有入学记录",
          },
          {
            id: "5",
            name: "2019年有入学记录",
          },
          {
            id: "6",
            name: "2020年有入学记录",
          },
        ],
        Data = getBasicData();

      //判断未登录状态,禁用表单元素
      if (info) {
        $("select,input").attr("disabled", false);
      } else {
        $("select,input").attr("disabled", true);
      }
      //判断是否登录
      $(".form").click(function () {
        if (info) {
          $(".mask").hide();
        } else {
          $(".mask").show();
        }
      });

      $("#district").html(addOption(Data.districtList));
      $("#houseType").html(addOption(Data.houseTypeList));
      $("#ownerShip").html(addOption(Data.ownerShipList));
      $("#orientation").html(addOption(Data.orientationList));
      $("#structure").html(addOption(Data.structureList));
      $("#property").html(addOption(Data.propertyList));
      $("#renovation").html(addOption(Data.renovationList));
      $("#schoolInfo").html(addOption(SchoolInfoList));

      //判断是否为和平区
      $("#district").change(function () {
        var val = $(this).val();
        if (val == "和平") {
          $(".schoolInfo").show();
        } else {
          $(".schoolInfo").hide();
        }
      });
      //判断产权
      $("#ownerShip").change(function () {
        var val = $(this).val();
        if (val == "公产房" || val == "使用权房") {
          $("#area").attr("placeholder", "请输入计租面积");
        } else {
          $("#area").attr("placeholder", "请输入计租面积");
        }
      });

      $(".submit-btn").click(function () {
        var datas = null,
          address = $("#address").val(),
          area = $("#area").val(),
          schoolInfo = $("#schoolInfo").val(),
          customerName = $("#customerName").val(),
          decorationType = $("#renovation").val(),
          district = $("#district").val(),
          floor = $("#floor").val(),
          houseId = $("#houseId").val(),
          houseType = $("#houseType").val(),
          houseOrientation = $("#orientation").val(),
          ownerShip = $("#ownerShip").val(),
          phoneNumber = $("#phoneNumber").val(),
          propertyManagementCompanyType = $("#property").val(),
          structure = $("#structure").val();

        if (!info) {
          $(".mask").show();
        } else if (!customerName) {
          alert("请输入您的姓名");
        } else if (!phoneNumber) {
          alert("请输入您的联系电话");
        } else if (!address) {
          alert("请输入您的详细地址");
        } else if (district == "请选择") {
          alert("请选择区域");
        } else if (houseType == "请选择") {
          alert("请选择房型");
        } else if (ownerShip == "请选择") {
          alert("请选择产别");
        } else if (houseOrientation == "请选择") {
          alert("请选择朝向");
        } else if (structure == "请选择") {
          alert("请选择结构");
        } else if (propertyManagementCompanyType == "请选择") {
          alert("请选择物业");
        } else if (decorationType == "请选择") {
          alert("请选择装修");
        } else if (!customerName) {
          alert("请输入楼层");
        } else if (!area) {
          alert("请输入面积");
        } else if (!houseId) {
          alert("请输入房本编号");
        } else {
          $(".mask").hide();
          if (!/^1[3456789]{1}[0-9]{9}$/.test(phoneNumber)) {
            alert("请输入11位正确的手机号");
          }
          datas = {
            address:
              address + "(" + schoolInfo + ")" + "(房本编号：" + houseId + ")",
            area: area,
            customerName: customerName,
            decorationType: decorationType,
            district: district,
            floor: floor,
            houseLayout: houseType,
            houseOrientation: houseOrientation,
            ownerShip: ownerShip,
            phoneNumber: phoneNumber,
            propertyManagementCompanyType: propertyManagementCompanyType,
            structure: structure,
            image: "",
            openId: info.customerOpenId,
          };
          freeEvalution(datas);
        }
      });

      function addOption(obj) {
        var html = "<option disabled selected>请选择</option>";
        $.each(obj, function (index, val) {
          html += "<option value=" + val.name + ">" + val.name + "</option>";
        });
        return html;
      }
      //获取基础数据
      function getBasicData() {
        var result = null;
        $.ajax({
          contentType: "application/json",
          type: "get",
          url: commomUrl + "BasicDataApi/GetBasicData",
          cache: false,
          dataType: "json",
          async: false,
          success: function (data) {
            // console.log(data.data)
            if (data.code == 200) {
              result = data.data;
            }
          },
        });
        return result;
      }
      //表单数据提交
      function freeEvalution(datas) {
        // var result = null;
        $.ajax({
          contentType: "application/json",
          type: "post",
          url: commomUrl + "HouseEvalutation/SubmitHouseEvalutaionInfo",
          cache: false,
          data: JSON.stringify(datas), //重点必须为一个变量如：data
          dataType: "json",
          async: false,
          success: function (data) {
            console.log(data);
            if (data.code == 200) {
              // result=data.data
              alert(
                "您的评估信息已收到，我们将人工对您的房屋进行评估，结果将在三到七个工作日内给您回复，您也可以到就近的连锁店进行咨询。"
              );
              document.getElementById("myform").reset();
            }
          },
        });
        // return result
      }
      getEvaluationHouseInfoList({
        current: 1,
        openId: "o5GGA4i3Q0mHnWyeVQsVhSElOw7I",
        pageSize: 300,
      });
      //获取评估列表
      function getEvaluationHouseInfoList(datas) {
        var result = null;
        $.ajax({
          contentType: "application/json",
          type: "post",
          url: commomUrl + "HouseEvalutation/GetHouseEvalutationList",
          cache: false,
          data: JSON.stringify(datas), //重点必须为一个变量如：data
          dataType: "json",
          async: false,
          success: function (data) {
            console.log(data.data);
            if (data.code == 200) {
              // result=data.data
              console.log("评估列表：" + data.data);
            }
          },
        });
        return result;
      }
    </script>
  </body>
</html>
